<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('Select Services')" />
</head>
<body class="gray-bg">
<input type="hidden" id="rowIds">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <input type="hidden" name="serId" th:value="${serId}">
                    <ul>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "system/request2";
    var modStatusDatas = [[${@dict.getType('sys_service_status')}]];

    $(function() {
        var options = {
            url: prefix + "/selMethodList",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'modId',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'modName',
                    title: '名称'
                },
                {
                    field: 'modDes',
                    title: '描述'
                },
                {
                    field: 'modStatus',
                    title: '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(modStatusDatas, value);
                    }
                },
                {
                    field: 'modAcqupara',
                    title: '采样参数集',
                    formatter: function(value, row, index) {
                        if(value == null){
                            return '<a href="javascript:void(0)"></a>';
                        }
                        // return '<a href="'+downloadUrl+'?id='+row.nmrFile.fileId+'"><i class="fa fa-search"></i></a>';
                        return '<a href="javascript:void(0)" onclick="detail(\'' + value + '\')"><i class="fa fa-search"></i></a>';
                    }

                },
                {
                    field: 'tamplateName',
                    title: '模板'
                },
                {
                    field: 'createBy',
                    title: '创建者'
                }]
        };
        $.table.init(options);
    });


    function submitHandler(index, layero) {
        var rows = $.table.selectFirstColumns();
        if (rows.length == 0) {
            $.modal.alertWarning("请选择一个方法");
            return;
        }
        $.modal.close();
        // 父页面的方法
        // activeWindow().selectUsers();
        // 父页面的变量
        // activeWindow().$('#input-select').html(rows.join());
    }

    function getSelections() {
        return $.table.selectColumns("modName",false);
    }

    function getIdSelections() {
        return $.table.selectFirstColumns();
    }

    $("#bootstrap-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) {
        var rows = $.common.equals("uncheck-all", e.type) ? rowsBefore : rowsAfter;
        var rowIds = $.table.affectedRowIds(rows);
        $("#rowIds").val(rowIds);
    });

    function detail(value) {
        var replace = value.replaceAll("|", "</br>");
        $.modal.alertSuccess(replace);
    }
</script>
</body>
</html>